<template>
  <el-form :inline="true">
    <el-row>
      <el-form-item v-if="sn" label="系统单号:">
            <span class="order-sn">
              {{value.sn}}
            </span>
      </el-form-item>
      <el-form-item label="采购单号:">
        <span class="order-sn">  {{value.orderSn}}</span>
      </el-form-item>
      <el-form-item label="采购日期:">
        {{value.orderDate}}
      </el-form-item>
      <el-form-item label="创建人:">
        {{nickName}}
      </el-form-item>
      <el-form-item label="供应商:">
        <a :href="value|supplyUrl" target="_blank" class="out-link">{{value|supplyName}}</a>
      </el-form-item>
      <el-form-item label="录入日期:">
        {{value.createTime}}
      </el-form-item>
    </el-row>
    <el-row class="more-params">
      <el-form-item label="到货数量 / 采购数量 / 已录数量:">
        <span class="red">{{value.arrivalNum}}</span> / <span>{{value.orderNum}}</span> / <span class="red"> {{value.enterNum}}</span>
      </el-form-item>

      <el-form-item label="库存数量:">
        {{value.arrivalNum-value.sellNum}}
      </el-form-item>

      <el-form-item label="销售数量:">
        {{value.sellNum}}
      </el-form-item>

      <el-form-item label="货币类型:">
        {{value|currency}}
      </el-form-item>
      <el-form-item label="采购价格:">
        {{value|symbol}}{{value.orderPrice}}
      </el-form-item>
      <el-form-item label="售出汇率:">
        {{value.exchangeRate}}
      </el-form-item>
      <el-form-item label="结算汇率:">
        {{value.closeExchangeRate}}
      </el-form-item>
      <el-form-item label="外币运费:">
        {{value|symbol}}{{value.globalFreight}}
      </el-form-item>
      <el-form-item label="运费:">
        ￥{{value.freight}}
      </el-form-item>
      <el-form-item label="结算总额 / 已录总额:">
        <span> ￥{{value.cost}} </span> / <span class="red">￥{{value.enterPrice}}</span>
      </el-form-item>
    </el-row>
  </el-form>
</template>
<script>
  export default {
    name: 'HPurchaseInfoDisplay',
    props: {
      value: {
        type: Object,
        default: function () {
          return {}
        }
      },
      sn: {
        type: Boolean,
        default: false
      }
    },
    computed: {
      nickName: function () {
        const creater = this.value.creater
        if (creater != null && creater != undefined) {
          return creater.nickName
        }
        return ''
      }
    },
    filters: {
      symbol: function (data) {
        if (data != null) {
          if (data.currency != null) {
            return data.currency.symbol
          }
        }
        return ''
      },
      supplyName: function (data) {
        if (data != null) {
          if (data.supply != null) {
            return data.supply.name
          }
        }
        return ''
      },
      supplyUrl: function (data) {
        if (data != null) {
          if (data.supply != null) {
            return data.supply.url
          }
        }
        return '#'
      },
      currency: function (data) {
        if (data != null) {
          if (data.currency != null) {
            return data.currency.symbol + data.currency.name
          }
        }
        return ''
      }
    },
  }
</script>
